﻿using Compass.Wasm.Shared.Wms;
using Zack.DomainCommons.Models;

namespace Compass.WmsService.Domain.Entities;

public record Inventory : AggregateRootEntity
{
    public Guid CargoId { get;private set; }

    public double Quantity { get; private set; }
    public double Diff { get; private set; }
    public DateTime CountTime { get;private set; }
    public Guid OperatorId { get; private set; }//入库人
    public string? Remarks { get; private set; }

    private Inventory(){ }

    public Inventory(Guid id,Guid cargoId,double quantity,double diff,DateTime countTime, Guid operatorId, string? remarks)
    {
        Id=id;
        CargoId=cargoId;

        Quantity = quantity;
        Diff = diff;

        CountTime = countTime;
        OperatorId=operatorId;
        Remarks=remarks;
    }

    public void Update(InventoryDto dto)
    {
        ChangeQuantity(dto.Quantity)
            .ChangeDiff(dto.Diff)
            .ChangeCountTime(dto.CountTime)
            .ChangeRemarks(dto.Remarks);

        NotifyModified();
    }

    public Inventory ChangeQuantity(double quantity)
    {
        Quantity=quantity;
        return this;
    }
    public Inventory ChangeDiff(double diff)
    {
        Diff=diff;
        return this;
    }
    public Inventory ChangeCountTime(DateTime countTime)
    {
        CountTime=countTime;
        return this;
    }
    public Inventory ChangeRemarks(string? remarks)
    {
        Remarks=remarks;
        return this;
    }
}